/*
 * this class is used by the system to create  many objects/singletons that the users uses
 * Author : Yuval Kovler 2011
 * 
 */

package implementation.client;


//import implementation.client.ConsoleUI;
import implementation.client.IUserInput.EUserAction;
import implementation.client.net.ClientConnectionManager;
import implementation.gui.GUIController;
import implementation.shared.CPacker;
import implementation.shared.CSerializer;
import implementation.shared.IPacker;
import implementation.shared.ISerializer;



public class CClientFactory {

	static String USER_INPUT_CONTENT="Content";
	static String USER_INPUT_FORUM_SELECTION="which forum would you like to see?";
	static String USER_INPUT_FRIEND_NAME="Friends name";
	static String USER_INPUT_PASSWORD="Password";
	static String USER_INPUT_POST_SELECTION="which post would you like to see?";
	static String USER_INPUT_THREAD_SELECTION="which thread would you like to see?";
	static String USER_INPUT_TOPIC="Topic";
	static String USER_INPUT_USERNAME="User Name";
	
	// Declarations of UserOutputInput
	private static IUserInput _MainScreenUserOutputInput;
	private static IUserInput _loginUserOutputInput;
	private static IUserInput _registerUserOutputInput;
	private static IUserInput _getForumUserOutputInput;
	private static IUserInput _getForumsUserOutputInput;
	private static IUserInput _getPostOutputInput;
	private static IUserInput _addPostUserOutputInput;
	private static IUserInput _editPostOutputInput;
	private static IUserInput _getThreadOutputInput;
	private static IUserInput _addThreadUserOutputInput;
	private static IUserInput _addFriendUserOutputInput;
	private static IUserInput _RemoverFriendUserOutputInput;
	//private static IUserOutputInput _getFriendsUserOutputInput;
	private static IUserInput _profileUserOutputInput;
		
	
	private static IEncryptor _encryptor= null;
	
	private static ISerializer _serializer= null;
	
	private static IPacker _packer = null;
	
	private static IClientConnectionManager _connectionManager = null;
	
	private static IServerStub _clientSideServer = null;
	
	private static IUI _UI = null;
	
	public static IEncryptor getEncrptorSingelton(){
		if (_encryptor == null) {
			//_encryptor = new CEncryptor();
			_encryptor = new IEncryptor() {
				
				@Override
				public String encrypt(String str) {
					return str;
				}
			};
		}
		return _encryptor;
	}
	
	public static IPacker getPackerSingelton(){
		if (_packer == null) {
			_packer = new CPacker();
		}
		return _packer;
	}
	
	
	public static ISerializer getSerializerSingelton(){
		if (_serializer == null) {
			_serializer = new CSerializer();
		}
		return _serializer;
	}
	
	public static IClientConnectionManager getConnectionManagerSingelton(){
		if (_connectionManager == null) {
			_connectionManager = new ClientConnectionManager();
		}
		return _connectionManager;
	}
	

	
	public static IServerStub getClientSideServerSingelton(){
		if (_clientSideServer == null) {
			_clientSideServer = new ServerStub();
		}
		return _clientSideServer;
	}
	
	
	public static IUI getUISingelton(){
		if (_UI == null) {
			//_UI = new ConsoleUI( );
			_UI = new GUIController();
		}
		return _UI;
	}
	

	
	public static IUserInput getMainScreen(){
		//main screen view
		_MainScreenUserOutputInput=new CUserInput();
		
		_MainScreenUserOutputInput.addUserOperation(EUserAction.EExit);
		
		_MainScreenUserOutputInput.addUserOperation(EUserAction.ELogin);
		_MainScreenUserOutputInput.addUserOperation(EUserAction.ERegister);
		
		return _MainScreenUserOutputInput;
	}
	
	public static IUserInput getloginScreen(){
		
		//login view
		 _loginUserOutputInput = new CUserInput();
			
		 _loginUserOutputInput.addUserOperation(EUserAction.EExit);
		 _loginUserOutputInput.addUserOperation(EUserAction.EBack);
		 _loginUserOutputInput.addUserOperation(EUserAction.ELogin);
		 
		 _loginUserOutputInput.addParam(EUserParam.EUsername); 
		 _loginUserOutputInput.addParam(EUserParam.EPassword);
		 
		 return _loginUserOutputInput;
	
	}
	
	
	public static IUserInput getRegisterScreen(){
		
		//register view
		 _registerUserOutputInput=new CUserInput();
			
		 _registerUserOutputInput.addUserOperation(EUserAction.EExit);
		 _registerUserOutputInput.addUserOperation(EUserAction.EBack);
		 			
		 _registerUserOutputInput.addUserOperation(EUserAction.ERegister);
		 _registerUserOutputInput.addParam(EUserParam.EUsername); 
		 _registerUserOutputInput.addParam(EUserParam.EPassword); 
		 
		 return  _registerUserOutputInput;
	}
	
	
	public static IUserInput getForumScreen(){
		 
		 //forum view
		 _getForumUserOutputInput=new CUserInput();
			
		 _getForumUserOutputInput.addUserOperation(EUserAction.EExit);
		 _getForumUserOutputInput.addUserOperation(EUserAction.ELogout);
		 _getForumUserOutputInput.addUserOperation(EUserAction.EBack);
		 _getForumUserOutputInput.addUserOperation(EUserAction.EProfile);
			
		 _getForumUserOutputInput.addUserOperation(EUserAction.EGetThread);
		 _getForumUserOutputInput.addUserOperation(EUserAction.EAddThread);
		 _getForumUserOutputInput.addParam(EUserParam.EID); 
		 return  _getForumUserOutputInput;
	}
	
	
	public static IUserInput getForumsScreen(){
		//forums view
		 _getForumsUserOutputInput=new CUserInput();
			
		 _getForumsUserOutputInput.addUserOperation(EUserAction.EExit);
		 _getForumsUserOutputInput.addUserOperation(EUserAction.ELogout);
		 _getForumsUserOutputInput.addUserOperation(EUserAction.EProfile);
			
		 _getForumsUserOutputInput.addUserOperation(EUserAction.EGetForum);
		 _getForumsUserOutputInput.addParam(EUserParam.EID); 


		 return  _getForumsUserOutputInput;
	}
	
	public static IUserInput getPostScreen(){
		
		 //post view
		 _getPostOutputInput=new CUserInput();
			
		 _getPostOutputInput.addUserOperation(EUserAction.EExit);
		 _getPostOutputInput.addUserOperation(EUserAction.ELogout);
		 _getPostOutputInput.addUserOperation(EUserAction.EBack);
		 _getPostOutputInput.addUserOperation(EUserAction.EProfile);
			
		 _getPostOutputInput.addUserOperation(EUserAction.EEditPost);
		 _getPostOutputInput.addUserOperation(EUserAction.ERemovePost);

		 return  _getPostOutputInput;
	}
	
	public static IUserInput getAddPostScreen(){
		
		 //add post view
		 _addPostUserOutputInput=new CUserInput();
			
		 _addPostUserOutputInput.addUserOperation(EUserAction.EExit);
		 _addPostUserOutputInput.addUserOperation(EUserAction.ELogout);
		 _addPostUserOutputInput.addUserOperation(EUserAction.EBack);
		 _addPostUserOutputInput.addUserOperation(EUserAction.EProfile);
			
		 _addPostUserOutputInput.addUserOperation(EUserAction.EAddPost);
		 _addPostUserOutputInput.addParam(EUserParam.ETopic); 
		 _addPostUserOutputInput.addParam(EUserParam.EContent); 

		 return  _addPostUserOutputInput;
	}
	
	
	public static IUserInput getEditPostScreen(){
		 
		//edit post view	 
		 _editPostOutputInput=new CUserInput();
			
		 _editPostOutputInput.addUserOperation(EUserAction.EExit);
		 _editPostOutputInput.addUserOperation(EUserAction.ELogout);
		 _editPostOutputInput.addUserOperation(EUserAction.EBack);
		 _editPostOutputInput.addUserOperation(EUserAction.EProfile);
			
		 _editPostOutputInput.addUserOperation(EUserAction.EEditPost);
		 _editPostOutputInput.addParam(EUserParam.ETopic); 
		 _editPostOutputInput.addParam(EUserParam.EContent);

		 return  _editPostOutputInput;
	}
	
	public static IUserInput getThreadScreen(){
		 
		//thread view
		 _getThreadOutputInput=new CUserInput();
			
		 _getThreadOutputInput.addUserOperation(EUserAction.EExit);
		 _getThreadOutputInput.addUserOperation(EUserAction.ELogout);
		 _getThreadOutputInput.addUserOperation(EUserAction.EBack);
		 _getThreadOutputInput.addUserOperation(EUserAction.EProfile);
			
		 _getThreadOutputInput.addUserOperation(EUserAction.EGetPost);
		 _getThreadOutputInput.addUserOperation(EUserAction.EAddPost);
		 _getThreadOutputInput.addUserOperation(EUserAction.ERemoveThread);		 
		 _getThreadOutputInput.addParam(EUserParam.EID); 
		 

		 return _getThreadOutputInput ;
	}
	public static IUserInput getAddThreadScreen(){
		
		 //add thread view
		 _addThreadUserOutputInput=new CUserInput();
			
		 _addThreadUserOutputInput.addUserOperation(EUserAction.EExit);
		 _addThreadUserOutputInput.addUserOperation(EUserAction.ELogout);		
		 _addThreadUserOutputInput.addUserOperation(EUserAction.EBack);
		 _addThreadUserOutputInput.addUserOperation(EUserAction.EProfile);
			
		 _addThreadUserOutputInput.addUserOperation(EUserAction.EAddThread);
		 _addThreadUserOutputInput.addParam(EUserParam.ETopic); 
		 _addThreadUserOutputInput.addParam(EUserParam.EContent);


		 return _addThreadUserOutputInput ;
	}
	
	public static IUserInput getAddFriendScreen(){

		
		 //add friend view
		 _addFriendUserOutputInput=new CUserInput();
			
		 _addFriendUserOutputInput.addUserOperation(EUserAction.EExit);
		 _addFriendUserOutputInput.addUserOperation(EUserAction.ELogout);
		 _addFriendUserOutputInput.addUserOperation(EUserAction.EBack);
		 _addFriendUserOutputInput.addUserOperation(EUserAction.EProfile);
			
		 _addFriendUserOutputInput.addUserOperation(EUserAction.EAddFriend);
		 _addFriendUserOutputInput.addParam(EUserParam.EUsername);
		 
		 return _addFriendUserOutputInput ;
	}
	
	public static IUserInput getRemoverFriendScreen(){
		
		 //remove friend view
		 _RemoverFriendUserOutputInput=new CUserInput();
			
		 _RemoverFriendUserOutputInput.addUserOperation(EUserAction.EExit);
		 _RemoverFriendUserOutputInput.addUserOperation(EUserAction.ELogout);
		 _RemoverFriendUserOutputInput.addUserOperation(EUserAction.EBack);
		 _RemoverFriendUserOutputInput.addUserOperation(EUserAction.EProfile);
			
		 _RemoverFriendUserOutputInput.addUserOperation(EUserAction.ERemoveFriend);
		 _RemoverFriendUserOutputInput.addParam(EUserParam.EUserID);
			
		 return  _RemoverFriendUserOutputInput;
	}
	
		public static IUserInput getProfileScreen(){
		
		//profile view
		 _profileUserOutputInput=new CUserInput();
			
		 _profileUserOutputInput.addUserOperation(EUserAction.EExit);
		 _profileUserOutputInput.addUserOperation(EUserAction.ELogout);
			
		 _profileUserOutputInput.addUserOperation(EUserAction.EGetAllForums);
		 _profileUserOutputInput.addUserOperation(EUserAction.EAddFriend);
		 _profileUserOutputInput.addUserOperation(EUserAction.ERemoveFriend);


		 return  _profileUserOutputInput;
	}



		 //*************************8
		 //need to think about
		 //**************************
		 
		 /*
		public static IUserOutputInput getGetFriendsScreen(){

			 return  ;
		}

		 
		 
	

		
		 //get friends list user
		 _getFriendsUserOutputInput=new CUserOutputInput();
		 _getFriendsUserOutputInput=new CUserOutputInput();
		 _getFriendsUserOutputInput.addUserOperation(EUserAction.ADD_FRIEND);
		 _getFriendsUserOutputInput.addUserOperation(EUserAction.REMOVE_FRIEND);
		 _getFriendsUserOutputInput.addUserOutput(USER_INPUT_FRIEND_NAME);
		*/
	
	
	
	
}
